package org.monkey.request.plugin.config;

import org.monkey.request.plugin.aspect.LogAnnotationParser;
import org.monkey.request.plugin.entity.RequestInfo;


public class RequestInfoContext {

  private static final ThreadLocal<RequestInfo> context = new ThreadLocal<>();
  private static final ThreadLocal<LogAnnotationParser> parser = new ThreadLocal<>();

  public static void add(RequestInfo requestInfo,LogAnnotationParser logAnnotationParser) {
    context.set(requestInfo);
    if (parser != null) {
      parser.set(logAnnotationParser);
    }
  }

  public static RequestInfo get() {
    return context.get();
  }
  public static LogAnnotationParser getParser() {
    return parser.get();
  }
  public static void remove() {
    context.remove();
    parser.remove();
  }
}
